from PIL import Image

# Load the image
image_path = 'C:\\Users\\crxc\\Pictures\\wandb\\论文2\\ssEMnet/wrap.tif'  # Replace with the path to your image
original_image = Image.open(image_path)

# Define the coordinates of the rectangle you want to crop
# (x1, y1, x2, y2) where (x1, y1) is the top-left corner and (x2, y2) is the bottom-right corner
rectangle_coords = (28, 17, 538, 530)  # Replace with your rectangle coordinates

# Crop the image using the defined coordinates
cropped_image = original_image.crop(rectangle_coords)

# Save the cropped image
cropped_image_path = 'C:\\Users\\crxc\\Pictures\\wandb\\论文2\\ssEMnet\\wrap.png'  # Replace with where you want to save the cropped image
cropped_image.save(cropped_image_path)
